package study.saas.order.repo;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import study.saas.order.entity.Order;
import study.saas.order.service.model.OrderStatus;
import study.saas.order.service.model.PaymentStatus;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;

@Repository
public interface OrderRepository extends JpaRepository<Order, Long> {

    //根据id查询
    Optional<Order> findById(Long orderId);

    // 根据订单号查询
    List<Order> findByOrderNumberContaining(String orderNumber);

    // 根据用户ID和订单状态查询
    List<Order> findByUserIdAndStatus(Long userId, OrderStatus status);

    // 根据支付状态查询
    List<Order> findByPaymentStatus(PaymentStatus paymentStatus);

    // 根据创建时间范围查询
    List<Order> findByCreateTimeBetween(LocalDateTime startDate, LocalDateTime endDate);
}